check file es_lock with path {{ elasticsearch_data_path }}/node.lock
  group es

check file es_bin with path {{ elasticsearch_bin_path }}/elasticsearch
  group es

check file es_ca_crt with path {{ elasticsearch_config_path }}/certs/ca/ca.crt
  group es

check file es_ca_key with path {{ elasticsearch_config_path }}/certs/ca/ca.key
  group es

check file es_yaml with path {{ elasticsearch_config_path }}/elasticsearch.yml
  group es

check process elasticsearch with pidfile {{ elasticsearch_data_path }}/elasticsearch.pid
  start program = "{{ elasticsearch_bin_path }}/elasticsearch -d -p {{ elasticsearch_data_path }}/elasticsearch.pid" with timeout 180 seconds
  stop program = "/usr/bin/pkill -F {{ elasticsearch_data_path }}/elasticsearch.pid" with timeout 180 seconds
  if failed
    host {{ ansible_host }}
    port {{ elasticsearch_http_port }}
    with timeout 180 seconds
    for 3 cycles
    then alert
  depends on es_lock,es_bin,es_ca_crt,es_ca_key,es_yaml
  group es
